<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_Controls_SelectModulePage extends Zend_View_Helper_Abstract
{
    public function selectModulePage($name, $module, $value, $attribs = null)
    {
        $pages = Core_Filesystem_File::getFilesByType(APPLICATION_PATH . '/modules/' . $module . '/views/scripts/public', 'phtml');
        if (is_array($pages)) {
            $options[] = $this->view->getTranslation('Select One');
            foreach ($pages as $page) {
                $page = Core_Toolbox_Regex::stripFileExtension($page);
                $options[$page] = $page;
            }
            $form = new Core_Form();
            $select = $form->createElement('select', $name, array(
                'multiOptions'  => $options,
            ));
            if (is_array($value)) {
                $select->setValue($value);
            }
            if (is_array($attribs)) {
                $select->setAttribs($attribs);
            }
            return $select;
        } else {
            return $this->view->getTranslation('There are no pages in this module');
        }
    }
}